﻿<?php 
require_once(dirname(__FILE__)."/../../libs/login/login.php");
require_once(dirname(__FILE__)."/../../libs/dbclass/dbconnect.php");
require_once(dirname(__FILE__)."/../../libs/string/libstr.php");
require_once(dirname(__FILE__)."/../../admin/libs/config_class.php");
$lg=new login();
$mc=new libstr();
$lg->checklogin("admin_member");//检验是否登录
$mc=new libstr();
$cf=new config();

//更新
$action=trim($_GET['act']);
$id=trim($_GET['id']);

//获得文档信息
if($action=='edit'&&$id!=''){
	$condition=" where id=".$id;
	$artInfo=$cf->getInfo('single_acticle',$condition);

}

if($mc->Ismp($_POST["addbtn"])!=""){
	$data=array();
	$id=$mc->request("id","");;
	$data['topicname']=$mc->request("topicname","");
	$data['content']=$mc->request("content","");
	$data['summary']=$mc->request("summary","");
	$data['status']=1;
	$data['updatetime']=time();
	
	
	if($action=='edit'){   //查询是有记录
		$where="`id`=$id";
		$db->update_data("single_acticle",$data,$where);
		$mc->msg("更新文章成功!",'single_article_list.php');
	}else{
		$data['createtime']=time();
		$db->add_data("single_acticle",$data);
		$mc->msg("添加文章成功!",'single_article_list.php');
	}
	
	
}

$path="单页文档添加";

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>上传文章</title>
<link rel="stylesheet" type="text/css" href="../../plug/swfupload/uploadify.css">
	<link href="../css/css.css" rel="stylesheet" type="text/css" />
	<link rel="stylesheet" href="../../plug/kindeditor/themes/default/default.css" />
	<!--文章图片css!-->
	<style>
.imgall{position: relative; width:100px; height:100px; float:left; margin-right:10px}

.imgall img{  }
.imgall span{ position:absolute; width:100px; height:32px;bottom:0px; display:none; }
.imgall:hover span{display:block;}
.imgall span input{float:right; cursor:pointer; background-image: url(../images/trash-alt-empty-32.png); width:32px; height:32px; border:0; }
</style>
	<script type="text/javascript" src="../js/jquery.js"></script>
	<script charset="utf-8" src="../../plug/kindeditor/kindeditor-min.js"></script>
	<script charset="utf-8" src="../../plug/kindeditor/lang/zh_CN.js"></script>
    <script>
			var editor;
			KindEditor.ready(function(K) {
				editor = K.create('textarea[name="content"]', {
					allowFileManager : true
				});
				
			});
		</script>

</head>
<body style="background:#fff"> 
<div class="content">
    <div class="right">
 
     <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
            <td width="100%" height="24" class="top_head">&nbsp;</td>
          </tr>
          <tr>
            <td valign="top">
                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td width="1%" align="right"  height="45">&nbsp;</td>
                    <td width="99%" >
                     <table width="100%" border="0" cellspacing="0" cellpadding="0">
                      <tr>
                        <td width="55%" style="padding-left:20px;padding-top:10px;"><img src="../images/head.gif" width="13" height="11"><b><?php echo $path;?></b><a href="single_article_list.php" style=" margin-left:20px; text-decoration:underline;">返回列表</a></td>
                        <td width="45%" align="right">&nbsp;</td>
                      </tr>
                    </table>
                    </td>
                  </tr>
                </table>
            </td>
          </tr>
   </table>
     <form action="" method="POST">
    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="liebiao">
      <tr>
        <td width="11%" height="40" align="right" valign="middle">文章名称：</td>
        <td height="40" valign="middle">
            <input type="text" name="topicname" id="topicname"  value="<?php echo $artInfo['topicname']?>"/> <font>（*文章名称不能为空）</font>
            <input type="hidden" name="act"  value="<?php echo $action;?>"/>
            <input type="hidden" name="id"  value="<?php echo $id;?>"/>
         </td>
        </tr>
      <tr>
      <tr>
        <td width="11%" height="40" align="right" valign="middle">内容简介：</td>
         <td height="auto" valign="top" style="padding-top:10px;padding-bottom:10px;"><textarea name="summary" style="width:552px;height:150px;border:1px solid #CCC;" maxlength="500" ><?php echo $artInfo['summary']?></textarea></td>

        </tr>
      <tr>
        <td height="auto" align="right" valign="top" style="padding-top:8px;">正文内容：</td>
        <td height="auto" valign="top" style="padding-top:10px;padding-bottom:10px;"><textarea id="content" name="content" style="width:898px;height:415px;visibility:hidden;"><?php echo htmlspecialchars($artInfo['content'])?></textarea></td>
      </tr>
       <tr>
          <td height="50" align="right" valign="middle">&nbsp;</td>
        <td> <input type="submit" name="addbtn" id="addbtn" value="提交保存"  style="width:100px; cursor:pointer"/></td>
      </tr>
   </table>
    </from>
    </div>
 </div>

</body>
</html>

